package com.lcxw.hxzbadmin.controller.chargecontroller;

import java.util.List;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import com.lcxw.hxzbapi.entity.pojo.YwpdChargeDetail;
import com.lcxw.hxzbapi.service.YwpdChargeDetailService;
import com.lcxw.hxzbcommon.common.StringUtil;

@Component
@Slf4j
public class ChargeDetailRealization {

    @Resource
    YwpdChargeDetailService chargeDetailService;

    /**
     * 1、动态获取充值记录方法
     */
    public List<YwpdChargeDetail> getChargeDetailDync(String userIdStr, String chargeMode,
        String fromTime, String endTime, String status, int pageIndex, int pageSize) {
        long userId = 0;
        if (null != userIdStr) {
            userId = Long.parseLong(userIdStr);
        }
        chargeMode = StringUtil.isEmpty(chargeMode) ? null : chargeMode;
        fromTime = StringUtil.isEmpty(fromTime) ? null : fromTime;
        endTime = StringUtil.isEmpty(endTime) ? null : endTime;
        status = StringUtil.isEmpty(status) ? null : status;
        pageIndex = (pageIndex - 1) * pageSize;

        List<YwpdChargeDetail> chargeDetails = chargeDetailService
            .selectDync(userId, chargeMode, fromTime, endTime, status, pageIndex, pageSize);

        return chargeDetails;
    }

    /**
     * 2、动态获取充值记录总条数
     */
    public int getSumDetailDync(String userIdStr, String chargeMode, String fromTime,
        String endTime, String status) {
        long userId = 0;
        if (null != userIdStr) {
            userId = Long.parseLong(userIdStr);
        }

        chargeMode = StringUtil.isEmpty(chargeMode) ? null : chargeMode;
        fromTime = StringUtil.isEmpty(fromTime) ? null : fromTime;
        endTime = StringUtil.isEmpty(endTime) ? null : endTime;
        status = StringUtil.isEmpty(status) ? null : status;

        return chargeDetailService
            .selectCountDync(userId, chargeMode, fromTime, endTime, status);
    }

}
